﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
<%@ Import Namespace="LangMauViet.Classes.Helper" %>
<div class="header">
    
    <% 
       string activeLink = HttpContext.Current.Request.RawUrl.ToLower();
       //int giftCnt = 0;
       string keyword = string.Empty;

       if (TempData["KeepKeyword"] != null)
       {
           keyword = (string)TempData["KeepKeyword"];
       }
       
       
    %>
    <a href="/">
        <img src="/App_Themes/Main.Wap/images/menu.png" height="100" style="margin: 20px 40px 0px 20px;" /></a>
    <a href="/">
        <img src="/App_Themes/Main.Wap/images/logo.png" class="logo" height="100" style="margin-top: 30px;" /></a>
    <% if (!ReferenceEquals(subscriber, null))
       { %>
    <a href="javascript:void(0);" onclick="ShowActionBox();">
        <div class="user_action">
            <img src='<%= UIHelper.GetAvatarImagePath(subscriber, true) %>' height="60" width="60" />
            <br />
            <b>
                <%= string.IsNullOrEmpty(subscriber.NickName) ? UIHelper.CropString(subscriber.UserName, 8) : UIHelper.CropString(subscriber.NickName, 8) %></b>
        </div>
    </a>
    <% }
       else
       { %>
    <a href="javascript:void(0);" onclick="ShowLogin();">
        <div class="user_icon">
            <img src="/App_Themes/GoBook.WAP/Images/ico_user.png" width="100" />
        </div>
    </a>
    <% } %>
    <a href="javascript:void(0);" onclick="ShowSearchBox();">
        <div class="search_icon">
            <img src="/App_Themes/GoBook.WAP/Images/ico_search.png" width="100" />
        </div>
    </a>
</div>
<% using (Html.BeginForm("ProductList", "Product", new { genreId = 0, categoryId = 0 }, FormMethod.Post, new { id = "formProductList" }))
   {%>
<div class="search" id="box_search">
    <div class="boxsearch m25">
        <input type="text" class="inputsearch" placeholder="Nhập tên sách hoặc tên tác giả ..."
            value="<%=keyword %>" id="txtHeaderSearch" name="txtHeaderSearch" onkeypress="return Search(event)" />
        <a href="javascript:void(0);" onclick="return SubmitSearch();">
            <img src="/App_Themes/GoBook.Wap/Images/ico_search.png" class="mright15 mtop15 right"
                width="50" height="50" /></a>
    </div>
</div>
<%} %>
<div class="login" id="box_login">
    <div class="mtop10 fw">
        <a href="<%=Url.Action("Registration","Account") %>" style="color: #000;">Đăng ký</a> | Đăng nhập</div>
    <center>
        <table width="50%" class="mtop20">
            <tr>
                <td>
                    <a href="<%=Url.Action("Logon", "Account") %>">
                        <img src="/App_Themes/GoBook.Wap/Images/gobook.png" width="70" height="70" /></a>
                </td>
                <td>
                    <a href="<%=Url.Action("Logon", "Account") %>">
                        <img src="/App_Themes/GoBook.Wap/Images/facebook.png" width="70" height="70" /></a>
                </td>
                <td>
                    <a href="<%=Url.Action("Logon", "Account") %>">
                        <img src="/App_Themes/GoBook.Wap/Images/twitter.png" width="70" height="70" /></a>
                </td>
                <td>
                    <a href="<%=Url.Action("Logon", "Account") %>">
                        <img src="/App_Themes/GoBook.Wap/Images/google.png" width="70" height="70" /></a>
                </td>
            </tr>
        </table>
    </center>
</div>
<% if (!ReferenceEquals(subscriber, null))
   { %>
<div class="link_action" id="box_link_user">
    
    <table width="100%">
        <tr>
            <td style="width: 25%" align="center" class='<%=activeLink.Contains("accountinforwap") || activeLink.Contains("purchasehistory")|| activeLink.Contains("addcredits")||activeLink.Contains("editaccountprofile")?"table_tab_active" :"tab_grey_w" %>'>
                <%=Html.ActionLink("Tài khoản của tôi","AccountInforWap","Account") %>
            </td>
            <td style="width: 25%" class='<%=activeLink.Contains("mynewbookmatehome")?"table_tab_active" :"tab_grey_w" %>' align="center">
                <%=Html.ActionLink("Trang cá nhân","MyNewBookmateHome","BookMate") %>
            </td>
            <td style="width: 25%;" class='<%=activeLink.Contains("bookshelf")?"table_tab_active" :"tab_grey_w" %>' align="center">
                <%=Html.ActionLink("Thư viện cá nhân","BookShelf","Account") %>
            </td>
            <td style="width: 25%;" class="tab_grey_w" align="center">
                <%= Html.ActionLink("Đăng xuất", "SignOut", "Account")%>
            </td>
        </tr>
    </table>
</div>
<% } %>
<input type="hidden" value="1" id="fs" />
<input type="hidden" value="1" id="fl" />
<input type="hidden" value="1" id="fa" />
<%--<div id="menu_top">
    <div class="box_menu_top">
        <ul class="clear">
            <li class="left menutop_item menutop_item_home"><a href='<%=Url.Action("Index", "Home") %>'
                class="ico_home">
                <img src="/App_Themes/GoBook.Main/Images/ico_home.png" alt="" id="home_img" width="30"
                    height="30" /></a></li>
            <li class="menu_top_line left"></li>
            <%if (parentCateList.Count > 0)
              {
                  foreach (var cate in parentCateList)
                  {
                      
            %>
            <li class="left menutop_item menutop_item_dropdown" id="menu_top<%=cate.ID %>"><a href="<%=Url.Action("ChildCategoryList","Category", new{ categoryId = cate.ID}) %>">
                <%=cate.Name %></a> </li>
            <li class="menu_top_line left"></li>
            <% }
              }
            %>
             <li class="left menutop_item menutop_item_dropdown"><a href="/Category/ChildCategoryList/-1">Về Gobook</a></li>
        </ul>
    </div>
</div>--%>
<script type="text/javascript">
    function ShowLogin() {
        var fl = $('#fl').val();
        if (fl == '1') {
            $('#box_login').slideDown();
            $('#fl').val(0);
        } else {
            $('#box_login').slideUp();
            $('#fl').val(1);
        }
        $('#fs').val(1);
        $('#box_search').hide();
    }
    function ShowSearchBox() {
        var fs = $('#fs').val();
        if (fs == '1') {
            $('#box_search').slideDown();
            $('#fs').val(0);
        } else {
            $('#box_search').slideUp();
            $('#fs').val(1);
        }
        $('#fl').val(1);
        $('#box_login').hide();
        $('#fa').val(1);
        $('#box_link_user').hide();
    }
    function ShowActionBox() {
        var fa = $('#fa').val();
        if (fa == '1') {
            $('#box_link_user').slideDown();
            $('#fa').val(0);
        } else {
            $('#box_link_user').slideUp();
            $('#fa').val(1);
        }
        $('#fs').val(1);
        $('#box_search').hide();
    }
    function Search(e) {
        var key;
        if (window.event)
            key = window.event.keyCode;     //IE 
        else
            key = e.which;     //firefox 

        if (key == 13) {
            var form = $('#formProductList').form;
            var keywords = $("#txtHeaderSearch").val();
            keywords = strip(keywords);
            keywords = keywords.replace(/\+/g, "");
            if (keywords == "" || !/[^\s]/.test(keywords) || keywords.length == 0 || keywords.isNull) {
                alert("Bạn hãy nhập từ khóa để tìm kiếm");
                return false;
            }

            $("#txtHeaderSearch").val(keywords);
            form.submit();
            return true;
        }
        return true;
    }
    function SubmitSearch() {

        var keywords = document.getElementById("txtHeaderSearch");
        keywords.value = strip(keywords.value);
        if (keywords.value == "" || !/[^\s]/.test(keywords.value) || keywords.value.length == 0 || keywords.value.isNull) {
            alert("Bạn hãy nhập từ khóa để tìm kiếm");
            return false;
        }

        $('#formProductList').submit();

        return true;
    }

    function strip(html) {
        html = html.replace(/<[^>]*>/g, '');
        return html;
    }
</script>